﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace BYRForum
{
    public partial class UserInfoPage : PhoneApplicationPage
    {
        public UserInfoPage()
        {
            InitializeComponent();
            textBlockUserId.Text = App.ArticleList.Items[App.ArticleItemChoose].Article_Item.author.Id;
            textBlockUserName.Text = App.ArticleList.Items[App.ArticleItemChoose].Article_Item.author.User_name;
            textBlockGender.Text = App.ArticleList.Items[App.ArticleItemChoose].Article_Item.author.Gender=="m"?"男":"女";
            textBlockAstro.Text = App.ArticleList.Items[App.ArticleItemChoose].Article_Item.author.Astro;
            textBlock7.Text = App.ArticleList.Items[App.ArticleItemChoose].Article_Item.author.Post_count;
            textBlock9.Text = App.ArticleList.Items[App.ArticleItemChoose].Article_Item.author.Score;
            textBlock11.Text = App.ArticleList.Items[App.ArticleItemChoose].Article_Item.author.Life;

            DateTime dtStart = new DateTime(1970, 1, 1);//这是发帖时间格式转换
            long lTime = long.Parse(App.ArticleList.Items[App.ArticleItemChoose].Article_Item.author.Last_login_time + "0000000");
            TimeSpan toNow = new TimeSpan(lTime);
            DateTime dtResult = dtStart.Add(toNow);
            textBlock13.Text = dtResult.ToString("yyyy-MM-dd HH:mm:ss");
            textBlock15.Text = App.ArticleList.Items[App.ArticleItemChoose].Article_Item.author.Last_login_ip;
            textBlock17.Text = App.ArticleList.Items[App.ArticleItemChoose].Article_Item.author.Is_online == "true" ? "在线" : "离线";
            App.ThreadDetailSourcePage = "UserInfoPage";
        }

        private void SendEmailClick(object sender, EventArgs e)
        {
            this.NavigationService.Navigate(new Uri("/BYRForum;component/EditMailPage.xaml?from=thread&sendId=" + 
                App.ArticleList.Items[App.ArticleItemChoose].Article_Item.author.Id, UriKind.Relative));
        }
    }
}